#include<bits/stdc++.h>
using namespace std;
const int INF=0x7fffffff;
int n,m,k,head[2010],cnt,idx[2010],S=0,T=2001,sum;
struct edge
{
	int v,next,val;
}e[100010];
void addedge(int x,int y,int z)
{
	e[cnt]=(edge){y,head[x],z};
	head[x]=cnt++;
	return;
}
bool check(int u)
{
	idx[u]=1;
	if(u==n)return true;
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(idx[v])continue;
		if(check(v))return true;
	}
	return false;
}
void bfs()
{
	memset(idx,0,sizeof(idx));
	queue<int>q;
	q.push(S);
	idx[S]=1;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=head[u];~i;i=e[i].next)
		{
			int v=e[i].v;
			if(idx[v]||!e[i].val)continue;
			idx[v]=idx[u]+1;
			q.push(v);
		}
	}
	return;
}
int dfs(int u,int _min)
{
	if(u==T)return _min;
	int ret=0,k;
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(idx[v]!=idx[u]+1||!e[i].val)continue;
		k=dfs(v,min(_min-ret,e[i].val));
		e[i].val-=k;
		e[i^1].val+=k;
		ret+=k;
		if(ret==_min)break;
	}
	return ret;
}
int dinic()
{
	int ret=0;
	while(true)
	{
		bfs();
		if(!idx[T])break;
		ret+=dfs(S,INF);
	}
	return ret;
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d%d%d",&n,&m,&k);
	int tmp1[20],tmp2[20][30];
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&tmp1[i],&tmp2[i][0]);
		for(int j=1;j<=tmp2[i][0];++j)
		{
			scanf("%d",&tmp2[i][j]);
			if(tmp2[i][j]==0)tmp2[i][j]=n+1;
			if(tmp2[i][j]==-1)tmp2[i][j]=n+2;
			if(j==1)continue;
			if(j==tmp2[i][0]&&tmp2[i][0]!=2)
			{
				addedge(tmp2[i][tmp2[i][0]],tmp2[i][1],0);
				addedge(tmp2[i][1],tmp2[i][tmp2[i][0]],0);
			}
			addedge(tmp2[i][j-1],tmp2[i][j],0);
			addedge(tmp2[i][j],tmp2[i][j-1],0);
		}
	}
	n+=2;
	if(!check(n-1))
	{
		puts("0");
		return 0;
	}
	memset(head,-1,sizeof(head));cnt=0;
	int ans=0;
	while(++ans)
	{
		addedge(S,ans*n-1,INF);
		addedge(ans*n-1,S,0);
		addedge(ans*n,T,INF);
		addedge(T,ans*n,0);
		if(ans==1)continue;
		for(int i=1;i<=n-2;++i)
		{
			addedge((ans-2)*n+i,(ans-1)*n+i,INF);
			addedge((ans-1)*n+i,(ans-2)*n+i,0);
		}
		for(int i=1;i<=m;++i)
		{
			int v2=ans%tmp2[i][0];
			if(!v2)v2=tmp2[i][0];
			int v1=v2-1;
			if(!v1)v1=tmp2[i][0];
			addedge((ans-2)*n+tmp2[i][v1],(ans-1)*n+tmp2[i][v2],tmp1[i]);
			addedge((ans-1)*n+tmp2[i][v2],(ans-2)*n+tmp2[i][v1],0);
		}
		sum+=dinic();
		if(sum>=k)break;
	}
	printf("%d\n",ans-1);
	return 0;
}
